package com.lguplus.servicepoi.request;

import org.jdom.Element;

import com.lguplus.servicepoi.exception.DBConnectionException;
import com.lguplus.servicepoi.exception.XMLValidationException;

/**
 * POI Regist Status Request
 */
public class POIRegistStatusRequest extends Request {

	/** POI Code */
	private double poiCode;
	
	public POIRegistStatusRequest() {
		super();
		
		this.poiCode = 0;
	}

	/* (non-Javadoc)
	 * @see com.lguplus.servicepoi.request.Request#runXmlAdaptor()
	 */
	@Override
	public void runXmlAdaptor() throws XMLValidationException, DBConnectionException{
		// H-0. Analyze Header
		headerElemToObject();
		
		// B-1. Get Child Node : poi_code
		Element poiCodeE = this.bodyElem.getChild("poi_code");
		if(poiCodeE != null)
			if(poiCodeE.getText().trim().length() == 0)
				throw new XMLValidationException("poi_code" + XMLValidationException.VALUE_MSG, XMLValidationException.VALUE_CD);
			else
				this.setPoiCode(poiCodeE.getText().trim());
		else
			throw new XMLValidationException("poi_code" + XMLValidationException.ELEMENT_MSG, XMLValidationException.ELEMENT_CD);
	}

	public double getPoiCode() {
		return poiCode;
	}

	public void setPoiCode(double poiCode) {
		this.poiCode = poiCode;
	}

	public void setPoiCode(String poiCode) {
		try{
			this.poiCode = Double.parseDouble(poiCode);
		}catch(Exception e){
			this.poiCode = 0;
		}
	}
	
	public void printBody(){
		System.out.println("poiCode = " + poiCode);
	}
}
